% \iffalse meta-comment --------------------------------------------------
% Copyright (C) 2021-2023 SJTUG
%
% Licensed under the Apache License, Version 2.0 (the "License");
% you may not use this file except in compliance with the License.
% You may obtain a copy of the License at
%
%     http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software 
% distributed under the License is distributed on an "AS IS" BASIS,
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and
% limitations under the License.
% ------------------------------------------------------------------------ \fi
% \iffalse
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{beamercolorthemesjtubeamer}[2023/11/25 v3.0.1 sjtubeamer color theme]
%</package>
% \fi
% \CheckSum{0}
% \StopEventually{}
% \iffalse
%<*package>
% ----------------------------------------------------------------------- \fi
%
% \subsection{Color Theme}
%
% Load SJTU VI Library to get the pre-defined color.
%    \begin{macrocode}
\RequirePackage{sjtuvi}
%    \end{macrocode}
%
%  \begin{macro}{\sjtubeamer@color@color}
%    \begin{macrocode}
\DefineOption{color}{color}{red}
\DefineOption{color}{color}{blue}
\ExecuteOptionsBeamer{red}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\sjtubeamer@color@lum}
%    \begin{macrocode}
\DefineOption{color}{lum}{light}
\DefineOption{color}{lum}{dark}
\ExecuteOptionsBeamer{dark}
%    \end{macrocode}
%  \end{macro}
%
%    \begin{macrocode}
\ProcessOptionsBeamer
%    \end{macrocode}
%
% Intermediate color palette depending on the choice of color theme.
%
% NOTICE: inner theme has a replica of the following code.
% To fullfill with the standfree requirements.
%    \begin{macrocode}
\if\EqualOption{color}{color}{red}
  \colorlet{cprimary}{sjtuRedPrimary}
  \colorlet{csecondary}{sjtuRedSecondary}
  \colorlet{ctertiary}{sjtuRedTertiary}
  \colorlet{cquanternary}{black}
\else
  \colorlet{cprimary}{sjtuBluePrimary}
  \colorlet{csecondary}{sjtuBlueSecondary}
  \colorlet{ctertiary}{sjtuBlueTertiary}
  \colorlet{cquanternary}{white}
\fi
%    \end{macrocode}
%
% Main color palatte depending on the choice of lumination.
% Especially, the \verb"structure" interface could not be derived from 
% any other color palette.
%    \begin{macrocode}
\setbeamercolor{structure}{fg=cprimary}
\if\EqualOption{color}{lum}{light}
  \setbeamercolor{palette primary}{bg=white,fg=cprimary}
  \setbeamercolor{palette secondary}{bg=white,fg=cprimary!50!csecondary}
  \setbeamercolor{palette tertiary}{bg=white,fg=csecondary}
\else
  \setbeamercolor{palette primary}{bg=cprimary,fg=white}
  \setbeamercolor{palette secondary}{bg=cprimary!50!csecondary,fg=white}
  \setbeamercolor{palette tertiary}{bg=csecondary,fg=white}
\fi
%    \end{macrocode}
%
% This part defines the color scheme of title.
%    \begin{macrocode}
\setbeamercolor{background canvas}{bg=white}
\setbeamercolor{normal text}{fg=black,bg=black!40}
\setbeamercolor*{block title}{parent=structure}
\setbeamercolor{titlelike}{bg=,fg=cprimary}
\setbeamercolor{title}{use={palette primary},fg=palette primary.fg,bg=}
\setbeamercolor{subtitle}{use={palette secondary},fg=palette secondary.fg,bg=}
\setbeamercolor{author}{use={palette primary},bg=,fg=palette primary.fg}
\setbeamercolor{institute}{parent=author}
\setbeamercolor{date}{parent=author}
%    \end{macrocode}
%
% Logo color system is now controlled by \verb"logo.fg".
% If you want to use a logo with its color definition in \verb"logo",
% use \verb"\insertlogo". Otherwise, if you want to use a logo that matches
% the current text color, use \verb"\usebeamertemplate{logo}".
%    \begin{macrocode}
\setbeamercolor{logo}{bg=,fg=cprimary}
%    \end{macrocode}
%
% This part defines the color of block title.
%    \begin{macrocode}
\setbeamercolor{block title}{fg=white,bg=cprimary!90}
\setbeamercolor{block title alerted}{use=alerted text,
  fg=white,bg=csecondary}
\setbeamercolor{block title example}{use=example text,
  fg=cquanternary,bg=ctertiary}
%    \end{macrocode}
%
% This part defines the color of block body.
%    \begin{macrocode}
\setbeamercolor{block body}{parent=normal text,use=block title,
  bg=block title.bg!15}
\setbeamercolor{block body alerted}{parent=normal text,
  use=block title alerted,bg=block title alerted.bg!15}
\setbeamercolor{block body example}{parent=normal text,
  use=block title example,bg=block title example.bg!15}
%    \end{macrocode}
%
% Set up the background color for stampblock.
% In case you want to change to something like \verb"cprimary!10".
%    \begin{macrocode}
\setbeamercolor{block body stamp}{bg=}
%    \end{macrocode}
%
% This part defines the color of footline.
%    \begin{macrocode}
\setbeamercolor{footnote}{fg=cprimary,bg=}
%    \end{macrocode}
%
% This part defines the color of part page, section page, and subsection page.
%    \begin{macrocode}
\setbeamercolor{part title}{parent={palette primary}}
\setbeamercolor{section title}{parent={palette secondary}}
\setbeamercolor{subsection title}{parent={palette tertiary}}
%    \end{macrocode}
%
% Set the footline color.
%    \begin{macrocode}
\setbeamercolor{section in head/foot}{fg=white,bg=cprimary}
\setbeamercolor{subsection in head/foot}{fg=cprimary,bg=cprimary!20}
\setbeamercolor{institute in head/foot}{fg=white,bg=}
\setbeamercolor{page number in head/foot}{fg=white,bg=}
%    \end{macrocode}
%
% Color patch for sidebar, shadow, and smoothtrees.
% WARNING: This is a replica from outer theme,
% just in case if you want to use color theme seperately.
% But it is useless in the overall theming.
%    \begin{macrocode}
\setbeamercolor{frametitle}{use=titlelike,bg=white,fg=titlelike.fg}
\setbeamercolor{frametitle right}{parent=subsection in head/foot}
%    \end{macrocode}
%
% As is native to beamer, you could also use \verb"\alert" command
% to highlight the text. The color is redirected to the cprimary.
%    \begin{macrocode}
\setbeamercolor{alerted text}{fg=cprimary}
%    \end{macrocode}
%
%
% \iffalse
%</package>
% \fi
% \Finale
\endinput
